<?php
class APP{
	static public function run(){
		$model=isset($_GET['m'])?$_GET['m']:'Index';
		$controller=isset($_GET['c'])?$_GET['c']:'Index';
		$action=isset($_GET['a'])?$_GET['a']:'Index';
		$class=$controller.'Controller';
		$path=APP_PATH.$model.'/Controller/'.$class.'.class.php';
		// define('TPL_PATH',APP_PATH.$model.'/View/'.$controller.'/Tpl/');
		// define('COM_PATH',APP_PATH.$model.'/View/'.$controller.'/Compile/');
		//默认开启session
		session_start();
		//POST传参是否为空
		define('IS_POST', !empty($_POST));
		//模块路径
		define('MODULE_PATH',APP_PATH.$model.'/');
		//模块名称
		define('MODULE',$model);
		//控制器名称
		define('CONTROLLER',$controller);
		// echo MODULE_PATH.'View/'.CONTROLLER;exit;
		//动作名称
		define('ACTION', $action);
		//网站根目录
		define('__ROOT__','http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']).'/');
		//网站入口路径
		define('__WEB__','http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']);
		//模块路径
		define('__MODULE__', __WEB__.'?m='.MODULE);
		//控制器路径
		define('__CONTROLLER__', __MODULE__.'&c='.CONTROLLER);
		//动作路径
		define('__ACTION__', __CONTROLLER__.'&a='.ACTION);
		//css文件夹路径
		define('__VIEW__',__ROOT__.'/'.MODULE_PATH.'View/');
		C(require EASYPHP_PATH.'Config.php');
		if(is_file(MODULE_PATH.'Config/Config.php')){
			C(require MODULE_PATH.'Config/Config.php');
		}
		require $path;
		$obj=new $class();
		$obj->$action();
		// p($Smarty);echo TPL_PATH;exit;
		// $Smarty=new Smarty();
		// $Smarty->template_dir=TPL_PATH;
		// $Smarty->compile_dir=COM_PATH;
		// p($Smarty);exit;
		// Smarty::template_dir=TPL_PATH;
		// Smarty::compile_dir=COM_PATH;
	}
}

?>